package com.google.code.mochaccino.framework.hibernate.provider.configuration.helper;
/*
 * Copyright 2012 Claude Houle claude.houle@gmail.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.util.Properties;
import org.hibernate.cfg.Environment;

/** Hibernate Debug Configuration */
public final class ConfigurationHelperDebug implements ConfigurationHelper {
	/** Format SQL */
	private boolean formatSQL = false;

	/** Show SQL */
	private boolean showSQL = false;

	/** Use Comments */
	private boolean useSQLComments = false;

	public static final ConfigurationHelperDebug verbose() {
		ConfigurationHelperDebug bean = new ConfigurationHelperDebug();
		bean.setFormatSQL( true );
		bean.setShowSQL( false );
		bean.setUseSQLComments( true );
		return bean;
	}

	public void setFormatSQL( boolean formatSQL ) {
		this.formatSQL = formatSQL;
	}

	public void setShowSQL( boolean showSQL ) {
		this.showSQL = showSQL;
	}

	public void setUseSQLComments( boolean useSQLComments ) {
		this.useSQLComments = useSQLComments;
	}

	@Override
	public void configure( Properties p ) {
		/* Debugging */
		p.put( Environment.FORMAT_SQL, Boolean.toString( formatSQL ) );
		p.put( Environment.SHOW_SQL, Boolean.toString( showSQL ) );
		p.put( Environment.USE_SQL_COMMENTS, Boolean.toString( useSQLComments ) );
	}
}
